.TH hal_pin_new "3hal" "2006-10-12" "LinuxCNC Documentation" "HAL"
.SH NAME

hal_pin_new \- Create a HAL pin

.SH SYNTAX

.HP
 int hal_pin_bit_new(const char *\fIname\fR, hal_pin_dir_t \fIdir\fR, hal_bit_t ** \fIdata_ptr_addr\fR, int \fIcomp_id\fR)

.HP
 int hal_pin_float_new(const char *\fIname\fR, hal_pin_dir_t \fIdir\fR, hal_float_t ** \fIdata_ptr_addr\fR, int \fIcomp_id\fR)

.HP
 int hal_pin_u32_new(const char *\fIname\fR, hal_pin_dir_t \fIdir\fR, hal_u32_t ** \fIdata_ptr_addr\fR, int \fIcomp_id\fR)

.HP
 int hal_pin_s32_new(const char *\fIname\fR, hal_pin_dir_t \fIdir\fR, hal_s32_t ** \fIdata_ptr_addr\fR, int \fIcomp_id\fR)

.HP
 int hal_pin_port_new(const char *\fIname\fR, hal_pin_dir_t \fIdir\fR, hal_port_t ** \fIdata_ptr_addr\fR, int \fIcomp_id\fR)

.HP
 int hal_pin_bit_newf(hal_pin_dir_t \fIdir\fR, hal_bit_t ** \fIdata_ptr_addr\fR, int \fIcomp_id\fR, const char *\fIfmt\fR, \fI...\fR)

.HP
 int hal_pin_float_newf(hal_pin_dir_t \fIdir\fR, hal_float_t ** \fIdata_ptr_addr\fR, int \fIcomp_id\fR, const char *\fIfmt\fR, \fI...\fR)

.HP
 int hal_pin_u32_newf(hal_pin_dir_t \fIdir\fR, hal_u32_t ** \fIdata_ptr_addr\fR, int \fIcomp_id\fR, const char *\fIfmt\fR, \fI...\fR)

.HP
 int hal_pin_s32_newf(hal_pin_dir_t \fIdir\fR, hal_s32_t ** \fIdata_ptr_addr\fR, int \fIcomp_id\fR, const char *\fIfmt\fR, \fI...\fR)

.HP
 int hal_pin_port_newf(hal_pin_dir_t \fIdir\fR, hal_port_t ** \fIdata_ptr_addr\fR, int \fIcomp_id\fR, const char *\fIfmt\fR, \fI...\fR)

.HP
 int hal_pin_new(const char *\fIname\fR, hal_type_t \fItype\fR, hal_pin_dir_t \fIdir\fR, void **\fIdata_ptr_addr\fR, int \fIcomp_id\fR)

.SH  ARGUMENTS
.IP \fIname\fR
The name of the pin
.IP \fIdir\fR

The direction of the pin, from the viewpoint of the component.  It may be one
of \fBHAL_IN\fR, \fBHAL_OUT\fR, or \fBHAL_IO\fR.  Any number of \fBHAL_IN\fR or
\fBHAL_IO\fR pins may be connected to the same signal, but at most one
\fBHAL_OUT\fR pin is permitted.  A component may assign a value to a pin that
is \fBHAL_OUT\fR or \fBHAL_IO\fR, but may not assign a value to a pin that is
\fBHAL_IN\fR.

.IP \fIdata_ptr_addr\fR
The address of the pointer-to-data, which must lie within memory allocated by
\fBhal_malloc\fR.

.IP \fIcomp_id\fR
A HAL component identifier returned by an earlier call to \fBhal_init\fR.

.IP \fIfmt, ...\fR
A printf-style format string and arguments

.IP \fItype\fR
The type of the param, as specified in \fBhal_type_t(3hal)\fR.

.SH DESCRIPTION
The \fBhal_pin_new\fR family of functions create a new \fIpin\fR object.  Once
a pin has been created, it can be linked to a signal object using
\fBhal_link\fR.  A pin contains a pointer, and the component that owns the pin
can dereference the pointer to access whatever signal is linked to the pin.
(If no signal is linked, it points to a dummy signal.)

There are functions for each of the data types that the HAL supports.  Pins may
only be linked to signals of the same type.

.SH RETURN VALUE
Returns 0 on success, or a negative errno value on failure.

.SH SEE ALSO
\fBhal_type_t(3hal)\fR, \fBhal_link(3hal)\fR
